home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / sbin / mkinitramfs-kpkg < prev    next >
Text File  |  2008-06-11  |  2KB  |  101 lines

  1. #!/bin/sh
  2. set -eu
  3.  
  4. STATEDIR=/var/lib/initramfs-tools
  5. supported_host_version=""
  6. supported_target_version=""
  7. outfile=""
  8.  
  9. # FIXME: drop script after Lenny (needed for Etch linux-images)
  10.  
  11. usage()
  12. {
  13.     cat >&2 << EOF
  14.  
  15. Usage: ${0} <-o outfile> [version]
  16.  
  17. Please use update-initramfs(8):
  18. ${0} exists for compatibility by kernel-package(5) calls.
  19. See mkinitramfs-kpkg(8) for further details.
  20. EOF
  21.     exit 1
  22. }
  23.  
  24. OPTIONS=`getopt -o m:o: --long supported-host-version:,supported-target-version: -n "$0" -- "$@"`
  25. # Check for non-GNU getopt
  26. if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
  27.  
  28. eval set -- "$OPTIONS"
  29.  
  30. while true; do
  31.     case "$1" in
  32.     -m)
  33.         # ignore
  34.         shift 2
  35.         ;;
  36.     -o)
  37.         touch $2
  38.         outfile="$(readlink -f "$2")"
  39.         shift 2
  40.         ;;
  41.     --supported-host-version)
  42.         supported_host_version="$2"
  43.         shift 2
  44.         ;;
  45.     --supported-target-version)
  46.         supported_target_version="$2"
  47.         shift 2
  48.         ;;
  49.     --)
  50.         shift
  51.         break
  52.         ;;
  53.     *)
  54.         echo "Internal error!" >&2
  55.         exit 1
  56.         ;;
  57.     esac
  58. done
  59.  
  60. if [ -n "$supported_host_version" ] || [ -n "$supported_target_version" ]; then
  61.     if [ -n "$supported_host_version" ]; then
  62.         host_upstream_version="${supported_host_version%%-*}"
  63.     fi
  64.     if [ -n "$supported_target_version" ]; then
  65.         target_upstream_version="${supported_target_version%%-*}"
  66.         if dpkg --compare-versions "$target_upstream_version" lt "2.6.12"; then
  67.             exit 2
  68.         fi
  69.     fi
  70.     exit 0
  71. fi
  72.  
  73.  
  74. if [ -z "${outfile}" ]; then
  75.     usage
  76. fi
  77.  
  78. # And by "version" we really mean path to kernel modules
  79. # This is braindead, and exists to preserve the interface with mkinitrd
  80. version="${1}"
  81.  
  82. case "${version}" in
  83. /lib/modules/*/[!/]*)
  84.     ;;
  85. /lib/modules/[!/]*)
  86.     version="${version#/lib/modules/}"
  87.     version="${version%%/*}"
  88.     ;;
  89. esac
  90.  
  91. case "${version}" in
  92. */*)
  93.     echo "$PROG: ${version} is not a valid kernel version" >&2
  94.     exit 1
  95.     ;;
  96. esac
  97.  
  98. # linux-image installs latest version
  99. mkinitramfs -o ${outfile} ${version}
  100. sha1sum "${outfile}" | sed -e 's/\.new//' > "${STATEDIR}/${version}"
  101.